<style lang="less">

</style>
<template>
    <div>
        <Drawer :closable="false" placement="right" v-model="drawerVisible" width="50%" :title="drawerTitle">
            <Row>
                <Col>
                    <Card :shadow="false">
                        <Row>
                            <Form ref="form" :model="form" :rules="formValidate" :label-width="80" style="position:relative">
                                <FormItem label="审核结果" prop="auditState" >
                                    <RadioGroup v-model="form.auditState" >
                                        <Radio :label="2" >通过</Radio>
                                        <Radio :label="3" >拒绝</Radio>
                                    </RadioGroup>
                                </FormItem>
                                <FormItem label="转换证明" prop="convertCertHtml" v-if="form.auditState == 2">
                                    <upload-input :fileUrl="form.convertCertHtml" :fileSize="1024" :fileWh="imgSize" @on-change="handleUpload" width="400px" ref="upload"></upload-input>
                                </FormItem>
                                <FormItem label="有效期" prop="validityTimeString" v-if="form.auditState == 2">
                                    <DatePicker  type="date" format="yyyy-MM-dd"  @on-change="examChange" v-model="form.validityTimeString" style="width:300px" placeholder="请输入证明有效期"></DatePicker>
                                </FormItem>
                                <FormItem label="拒绝原因" prop="reason" v-if="form.auditState == 3">
                                    <Input v-model="form.reason" :readonly="disabledSingle" style="width:600px" placeholder="请输入拒绝原因"/>
                                </FormItem>
                                <Form-item class="br" v-if="!disabledSingle">
                                    <Button type="primary" :loading="submitLoading" @click="handelSubmit" style="width:80px">提交</Button>
                                    <Button @click="handelCancel">取消</Button>
                                </Form-item>
                                <Spin size="large" fix v-if="loading"></Spin>
                            </Form>
                        </Row>
                    </Card>
                </Col>
            </Row>
        </Drawer>
    </div>
</template>
<script>
    import {changeSetStatus} from "@/api/bus";
    import uploadInput from "@/views/my-components/flyme/upload-input";
    // 表情包配置 自定义表情可在该js文件中统一修改
    import {sina} from "@/libs/emoji";
    export default {
        name: "change-drawer",
        components: {
            uploadInput
        },
        data() {
            return {
                imgSize : "750*566",
                disabledSingle: false,
                picVisible: false,
                fileUrl: "",
                loading: false, // 表单加载状态
                drawerTitle: "国开注册申请审核",
                drawerVisible: false,
                form: {
                    id: '',
                    reason: '',
                    validityTimeString: '',
                    convertCertHtml: '',
                    auditState: 2,
                    sysUsercertificateId: ''
                },
                formValidate: {
                    reason: [{required: true, message: "拒绝原因不能为空", trigger: "blur"}],
                    validityTimeString: [{required: true, message: "有效期不能为空", trigger: "blur"}],
                    convertCertHtml: [{required: true, message: "请上传转换证明", trigger: "blur"}]
                },
                submitLoading: false, // 添加或编辑提交状态
            };
        },
        methods: {
            showDrawer(params) {
                this.form.id = params.id
                this.form.sysUsercertificateId = params.sysUsercertificateId
                this.drawerVisible = true;
            },
            handelSubmit() {
                this.$refs.form.validate(valid => {
                    if (valid) {
                        this.form.validityTimeString = this.form.validityTimeString + " 00:00:00"
                        this.submitLoading = true;
                        console.info(this.form)
                        changeSetStatus(this.form).then(res => {
                            this.submitLoading = false;
                            if (res.status === true) {
                                this.$Message.success("操作成功");
                                this.$parent.getDataList();
                                this.drawerVisible = false;
                            }
                        });
                    }
                });
            },
            examChange(data1,data2){
                this.form.validityTimeString = data1;
            },
            handleUpload(v) {
                if (v.fileUrl) {
                    this.form.convertCertHtml = v.fileUrl;
                }else{
                    this.form.convertCertHtml = v;
                }
            },
            handelCancel() {
                this.drawerVisible = false;
            }
        },
        mounted() {

        },
        watch: {

        }
    };
</script>